const crypto = require('crypto');
require('dotenv').config();

const defaultSalt = process.env.MD5_SALT || 'uni-app-salt';

exports.md5 = (str) => {
  return crypto.createHash('md5').update(str).digest('hex');
};

exports.md5WithSalt = (str, salt = defaultSalt) => {
  return crypto.createHash('md5').update(str + salt).digest('hex');
};